#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>


struct exam
{
	int data1;
	int data2;
	int res;
};


void *fun(void *arg)
{
	struct exam *p = (struct exam *)arg;

	p->res = p->data1 + p->data2;

}

int main()
{
	pthread_t tid = 0;
	int ret = 0;
	int data1 = 0,data2 = 0;
	int res = 0;

	data1 = 23;
	data2 = 12;

	struct exam obj;
	memset(&obj,0,sizeof(obj));

	obj.data1 = data1;
	obj.data2 = data2;

	ret = pthread_create(&tid,NULL,fun,&obj);//&obj发送，也接收！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
	if(ret != 0)
	{
		perror("pthread_create");
		exit(-1);
	}

	pthread_join(tid,NULL);

	res = obj.res;

	printf("res = %d\n",res);

	return 0;
}


